<%@ page language="java" errorPage="/error.jsp" pageEncoding="UTF-8"
         contentType="text/html;charset=utf-8" %>
<%@ include file="/common/taglibs.jsp" %>
<head>
    <title>优惠券添加</title>

</head>
<body>
<div id="wrapper">
    <c:set var="left">coupon</c:set>
    <%@ include file="/include/left/operation.jsp" %>

    <div id="page-wrapper" class="gray-bg">


        <div class="row wrapper border-bottom white-bg page-heading">
            <div class="col-lg-10">
                <h2>优惠券添加</h2>
                <ol class="breadcrumb">
                    <li>
                        <a href="${ctx}/coupon/">优惠券管理</a>
                    </li>
                    <li>
                        <a>优惠券管理</a>
                    </li>
                    <li class="active">
                        <strong>优惠券添加</strong>
                    </li>
                </ol>
            </div>
        </div>


        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-lg-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-content">
                            <s:form id="couponForm" action="coupon!save.action" class="form-horizontal" method="post" namespace="">
                                <input type="hidden" name="redirect" value="/coupon/"/>

                                <div class="form-group"><label class="col-sm-2 control-label">优惠券标题</label>
                                    <div class="col-sm-6">
                                        <input type="text" name="coupon.title" class="form-control  validate[required]" placeholder="请输入优惠券标题">
                                    </div>
                                </div>

                                <div class="form-group"><label class="col-sm-2 control-label">开始时间</label>
                                    <div class="col-sm-6">
                                        <input type="text" name="coupon.startTime" id="startTime" class="form-control  validate[required]" readonly placeholder="请输入优惠券开始时间">
                                    </div>
                                </div>

                                <div class="form-group"><label class="col-sm-2 control-label">结束时间</label>
                                    <div class="col-sm-6">
                                        <input type="text" name="coupon.endTime" id="endTime" class="form-control  validate[required]" readonly placeholder="请输入优惠券结束时间">
                                    </div>
                                </div>

                                <div class="form-group"><label class="col-sm-2 control-label">面值</label>
                                    <div class="col-sm-6">
                                        <input type="text" name="coupon.money" class="form-control  validate[required,custom[number]]" placeholder="请输入优惠券面值">
                                    </div>
                                </div>

                                <div class="form-group"><label class="col-sm-2 control-label">使用条件</label>
                                    <div class="col-sm-6">
                                        <input type="text" name="coupon.requirement" class="form-control  validate[required,custom[number]]" value="0.0" placeholder="请输入使用条件，单位元">
                                    </div>
                                </div>

                                <div class="form-group"><label class="col-sm-2 control-label">总库存数</label>
                                    <div class="col-sm-6">
                                        <input type="text" name="coupon.total" class="form-control  validate[required,custom[number]]" value="9999" placeholder="请输入总库存数">
                                    </div>
                                </div>

                                <div class="hr-line-dashed"></div>
                                <div class="form-group">
                                    <div class="col-sm-4 col-sm-offset-2">
                                        <button class="btn btn-white" type="button"
                                                onclick="javascript:history.back(-1);">取消
                                        </button>
                                        <button class="btn btn-primary" id="submitButton" type="submit" data-loading-text="提交中..." >提交
                                        </button>
                                    </div>
                                </div>
                            </s:form>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <%@ include file="/common/footer.jsp" %>


    </div>

</div>

<%@ include file="/common/scripts.jsp" %>
<%@ include file="/common/validate.jsp" %>
<%@ include file="/common/script/cxcalendar.jsp" %>


<script>
    $('#couponForm').validationEngine({
        promptPosition: 'topLeft',
        onValidationComplete:  function(form, status){//验证回调函数（阻断提交）
            if(status){//当所有验证通过后再执行
                submitForm();
            }
        }
    });

    $('#startTime').cxCalendar({
        type: 'datetime',
        format: 'YYYY-MM-DD HH:mm:ss'
    });
    $('#endTime').cxCalendar({
        type: 'datetime',
        format: 'YYYY-MM-DD HH:mm:ss'
    });

    function submitForm() {
        var _startTime = $('#startTime').val();
        var _endTime = $('#endTime').val();
        if (_startTime >= _endTime) {
            layer.msg('请输入合理的时间');
        } else {
            $('#submitButton').button('loading')
            $('#couponForm').submit();
        }
    }

</script>

</body>

